package com.mvvmhabit.org.binding.viewadapter.edittext

import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText
import androidx.databinding.BindingAdapter
import com.mvvmhabit.org.binding.command.BindingCommand

/**
 * @Date: 2020/11/19 14:55
 * @Author:小妖
 * @Description: EditText 输入框确定监听事件
 */

/*@BindingAdapter(value = ["OnEditorActionCommand"])
fun setOnEditorActionCommand(editText: EditText, onEditorActionCommand: BindingCommand<Any>) {
    editText.setOnEditorActionListener { _, _, _ ->
        onEditorActionCommand.execute()
        return@setOnEditorActionListener true
    }
}*/

@BindingAdapter(value = ["onEditorActionCommand"])
fun setOnEditorActionCommand(
    editText: AppCompatEditText,
    onEditorActionCommand: BindingCommand<Any>
) {
    editText.setOnEditorActionListener { _, _, _ ->
        onEditorActionCommand.execute()
        return@setOnEditorActionListener true
    }
}